
const Home = () => import('@/views/Home');
const Search = () => import('@/views/Search');
const Login = () => import('@/views/Login');
const Register = () => import('@/views/Register');
const Detail = () => import('@/views/Detail');
const AddShopSuccess = () => import('@/views/AddShopSuccess');
const ShopCart = () => import('@/views/ShopCart');
const Pay = () => import('@/views/Pay');
const PaySuccess = () => import('@/views/PaySuccess');
const Trade = () => import('@/views/Trade');
const Center = () => import('@/views/Center');
const MyOrder = () => import('@/views/Center/MyOrder');
const GroupOrder = () => import('@/views/Center/GroupOrder');

export default [
    {
        path: '/',
        redirect: '/home'

    },
    {
        name: 'Home',
        path: '/home',
        component: Home
    }, 
    {
        name: 'Register',
        path: '/Register',
        component: Register,
        meta: {
            isHiddle: true,
        }
    },
    {
        name: 'Login',
        path: '/Login',
        component: Login,
        meta: {
            isHiddle: true,
        },
        
    }, 
    {
        name: 'Search',
        path: '/Search/:keyword?',
        component: Search,
        props: (route) => {
            return {
                keyword: route.params.keyword,
                keyword1: route.query.keyword1,
            }
            
        }
    },
    {
        name: 'Detail',
        path: '/Detail/:goodsId?',
        component: Detail
    },
    {
        name: 'AddShopSuccess',
        path: '/AddShopSuccess',
        component: AddShopSuccess,
        beforeEnter: (to, from, next) => {
            let skuNum = to.query.skuNum;
            let skuInfo = sessionStorage.getItem('SKUINFO_KEY');
            if(skuNum && skuInfo) {
                next()
            }else {
                alert('必须携带skunum')
                next('/')
            }
        }
    },
    {
        name: 'ShopCart',
        path: '/ShopCart',
        component: ShopCart
    },
     {
        name: 'Pay',
        path: '/Pay',
        component: Pay,
        beforeEnter: (to, from, next) => {
            if(from.path === '/Trade') {
                next()
            }else {
                next('/')
            }
        }
    },
     {
        name: 'PaySuccess',
        path: '/PaySuccess',
        component: PaySuccess
    },
     {
        name: 'Trade',
        path: '/Trade',
        component: Trade,
        beforeEnter: (to, from, next) => {
            if(from.path === '/ShopCart') {
                next()
            }else {
                next('/')
            }
        }
    },
     {
        name: 'Center',
        path: '/Center',
        component: Center,
        children: [
            {
                path: 'myorder',
                component: MyOrder
            },
            {
                path: 'grouporder',
                component: GroupOrder
            }
        ]
    }


]
